<?php
/**
 * 正则匹配字符串中的数字
 * @param $string
 * @return mixed
 */
function myExplodeNumbers($string)
{
    preg_match_all("/[0-9\.?]+/",$string,$array);
    return $array[0];
}


function createOrderSn($uid = "")
{
    return date("YmdHis").rand(1000,9999).$uid;
}

function createPayCalBackCode($uid,$type="wx")
{
    return md5($type.uniqid($uid).rand(1000,9999));
}
function dealWithImgInHtml($content,$basUrl)
{
    $pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
    $content = preg_replace($pregRule, '<img src="'.$basUrl.'${1}" style="max-width:100%">', $content);
    return $content;
}
function dealWithPhoneNumber($phone)
{
    $start = substr($phone,0,3);
    $end = substr($phone,-4);
    return $start."****".$end;
}
function dealWithHtmlContent($content,$len = 250)
{
    $content = strip_tags($content);
    if (mb_strlen($content) > $len) {
        return mb_substr($content,0,$len)."...";
    }else{
        return $content;
    }
}

function getFileExtension($fileName)
{
    $arr = explode(".",$fileName);
    return $arr[array_key_last($arr)];
}

;